package net.wantongtech.xa.uploadbasicinfo.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.io.File;

/**
 * SCP配置
 *
 * @author MaShibo
 * 日期 :  2020/2/2
 */
@Data
@Component
@ConfigurationProperties("scp")
public class SCPClientConfig {

    private String host;

    private int port = 22;

    private String username;

    private String password;

    /**
     * 前缀访问路径
     */
    private String prefixPath;

    /**
     * 本地保存路径
     */
    private String localStorePath;

    @PostConstruct
    public void init() {
        File dir = new File(localStorePath);
        if (!dir.exists() && !dir.mkdirs()) {
            throw new IllegalStateException(String.format("文件目录%s创建失败", dir));
        }
    }
}
